#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > dpt_hbr.info <<%EOF%
   dpt_hbr
   -------
   Molecule:       HBr in C2v
   Wave Function:  CCS, CCSD / AhlrichsVDZ (frozen core)
   Test Purpose:   First-order relativistic corrections
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > dpt_hbr.mol <<%EOF%
BASIS
Ahlrichs-VDZ      
First-order relativistic corrections (frozen core)

    2    2  X  Y      1.00D-15
       35.0   1
Br      0.00000000000000    0.00000000000000    0.00000000000000       *
        1.0   1
H       0.00000000000000    0.00000000000000    2.67207254785060       *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > dpt_hbr.dal <<%EOF%
**DALTON INPUT
.RUN WAVE FUNCTIONS
**INTEGRAL
.DIPLEN
.THETA
.EFGCAR
.SECMOM
.DARWIN
.MASSVELO
.DPTPOT
.KINENER
**WAVE FUNCTION
.CC
*SCF INP
.THRESH
 1.0D-10
*CC INP
.CCS
.CCSD
.PRINT
 4
.THRENR
1.0D-10
.THRLEQ
1.0D-07
.FROIMP
 5 2 2 0
 0 0 0 0
*CCFOP
.ALLONE
.DPTECO
.2ELDAR
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >dpt_hbr.check
cat >>dpt_hbr.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#        DPTONE:    -56.095261326
#        DPTREO:     17.079554222
#        DPTTWO:      7.625937223
#        Total first-order DPT correction:    -31.389769882
#        1-elec. Darwin term:     81.455592992
#        Mass-Velocity term:    -112.402123687
#        Mass-Velocity + 1-elec. Darwin terms:     -30.946530695
#        2-elec. Darwin term:      -0.442936961
#        Total relativistic correction:     -31.389467655
#
#        Total first-order DPT correction:    -31.389664355
#        Total relativistic correction:     -31.389165433

CRIT1=`$GREP "Total first-order DPT correction:    \-31\.389769" $log | wc -l`
TEST[1]=`expr   $CRIT1`
CTRL[1]=1
ERROR[1]="CCS first-order DPT correction not correct"

CRIT2=`$GREP "Total first-order DPT correction:    \-31\.389664" $log | wc -l`
TEST[2]=`expr   $CRIT2`
CTRL[2]=1
ERROR[2]="CCSD first-order DPT correction not correct"

CRIT3=`$GREP "Total relativistic correction:     \-31\.389467" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=1
ERROR[3]="CCS first-order Pauli correction not correct"

CRIT4=`$GREP "Total relativistic correction:     \-31\.389165" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
ERROR[4]="CCSD first-order Pauli correction not correct"

PASSED=1
for i in 1 2 3 4
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%

chmod +x dpt_hbr.check
#######################################################################
